//建一个request.js
// const BASE_URL = 'http://39.101.128.216:8086'   //后端给的url
// const BASE_URL = 'https://jjwyapitest.ldzx1688.com'   //后端给的url
const BASE_URL = 'https://jjwyapi.ldzx1688.com'   //后端给的url

// 传入请求参数
// method: method,
// // 配置请求类型
// header: method == 'get' ? {'token': token, 'X-Requested-With': 'XMLHttpRequest',"Accept": `application/json, text/plain, */*`,"Content-Type": "application/json; charset=UTF-8"} : {'token': token,'X-Requested-With': 'XMLHttpRequest','Content-Type': 'application/json; charset=UTF-8'},
export const myRequest = (options) => {
return new Promise((resolve,reject)=> {
  let authtoken = uni.getStorageSync('authtoken')
  uni.request({
    url:BASE_URL + options.url,
    data:options.data || {},
    method:options.method || 'get',
    header: options.method == 'get' ? 
    {'token': uni.getStorageSync('authtoken'),
     'X-Requested-With': 'XMLHttpRequest',
     "Accept": `application/json, text/plain, */*`,
     "Content-Type": "application/x-www-form-urlencoded"} : 
     {'token': uni.getStorageSync('authtoken'),
     'X-Requested-With': 'XMLHttpRequest',
     'Content-Type': 'application/x-www-form-urlencoded'},
    // header:{
    //     'Content-type': 'application/json',
    // 	"X-Auth-Token": uni.getStorageSync('authtoken')  //这里的token指的是微信授权登录的token，用来判断小程序是否属于登录状态
    // },
    dataType:'json',
    success:res => {
      if(res.data.code !== 0){
      }
      resolve(res)
    },
    fail:err => {
      // uni.showToast({
      // 	title:"请求接口失败",
      // })
      console.log('err',err)
      reject(err)
    }
  })
}) 
}
